#pragma once
#include "CXcpObjectBase.h"
#include "CXcpObjectThreadSafeAddRefPolicy.h"
#include "IMediaQueue.h"

class CMediaQueueManager;
class CMediaQueueItem;

class CMediaQueue :
	public CXcpObjectBase<IMediaQueue,CXcpObjectThreadSafeAddRefPolicy>
{

public: 
	static HRESULT Create(CMediaQueueManager * pManager, struct IMediaQueueClient * pClient, struct ICoreServices * pCore, CMediaQueue * * ppQueue);
	virtual ~CMediaQueue();
	virtual HRESULT ProcessQueue();
	virtual HRESULT Shutdown();
	virtual HRESULT AddMediaEvent(struct IObject * pState, struct IMediaQueueTest * pTest);

protected: 
	CMediaQueue();
	HRESULT Initialize(CMediaQueueManager * pManager, struct IMediaQueueClient * pClient, struct ICoreServices * pCore);
private: 
	CMediaQueueManager * m_pManager;
	struct IMediaQueueClient * m_pClient;
	struct ICoreServices * m_pCoreNoRef;
	struct IPALCriticalSection * m_pLock;
	CMediaQueueItem * m_pHead;
	CMediaQueueItem * m_pTail;
	XUINT32 m_fShutdown;
};